package ui.client;

import java.util.ArrayList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * the interface of ChatService defines the operation
 * of chat through gwt rpc
 * @author wangkaidi
 *
 */
public interface ChatService extends RemoteService {

	public static final String SERVICE_URI = "ChatService";

	public static class Util {

		public static ChatServiceAsync getInstance() {

			ChatServiceAsync instance = (ChatServiceAsync) GWT
					.create(ChatService.class);
			ServiceDefTarget target = (ServiceDefTarget) instance;
			target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
			return instance;
		}
	}
	
	/**
	 * try to login to the system.	 * 
	 * @param username 
	 * @param password
	 * @return the login result,if success,it will return "true"
	 * else it will return "false"
	 */
	public String login(String protocolname,String username,String password,String domail,String host,int port);
	
	/**
	 * logout the system
	 */
	public void disconnect();
	
	/**
	 * send a message to a specific user.
	 * message's from attribute must be the user itself
	 * @param message
	 * @return. if the send operation success,it will return "true"
	 * else it will return "false"
	 */
	public String send(InstantMessage message);
	
	/**
	 * receive a list of Message.
	 * if there is no message,this method will
	 * block
	 * @return
	 */
	public ArrayList<InstantMessage> receive();
	
	/**
	 * get a group Arraylist of friends
	 * @return
	 */
	public ArrayList<Group> getGroups();
	
	/**
	 * this method will receive a list
	 * of UserPresence change.
	 * it will be blocked ,until there is
	 * reply
	 * @return
	 */
	public ArrayList<UserPresence> presenceChange();
	

}
